/*
 * @Author: yxfan
 * @Date: 2023-07-03 21:04:01
 * @LastEditTime: 2023-07-03 21:14:40
 * @FilePath: /umi-demo/src/pages/demo/ZombieChildren/child.js
 * @Description:
 */
import { useEffect } from 'react';
import { useSelector, useDispatch } from 'umi';

export default () => {
    const dispatch = useDispatch();
    const { num } = useSelector((state) => state.zombieChildren);
    useEffect(() => {
        console.log('!!!!');
    }, [num]);

    function add() {
        dispatch({
            type: 'zombieChildren/addNum',
            payload: 1,
        });
    }

    function sub() {
        dispatch({
            type: 'zombieChildren/subNum',
            payload: 1,
        });
    }
    return (
        <div>
            <h2>子节点: {num}</h2>
            <button onClick={add}>+</button>
            <br />
            <button onClick={sub}>-</button>
        </div>
    );
};
